from tools.abs_mouse_recorder import run
from tools.abs_mouse_recorder import AbsMouseRecorder
import keyboard
from tools.enum_window import set_genshin_window_position
from tools.beep import beep
from tools.beep import end_beep
from bdtime import Time


def main():
    # save_file_name = "试用活动"
    # save_file_name = "离开试用关卡"
    # save_file_name = "进入试用关卡.json"
    # save_file_name = "离开试用关卡.json"
    save_file_name = "test_1"

    # save_file_name = "测试"

    play_record = True
    # play_record = False

    # play_target = True
    play_target = False

    # need_press_alt = True
    need_press_alt = False

    hotkey__until = 'alt + x'

    # hotkey__start = None
    hotkey__start = 'alt + `'

    if 0:
        from tools import ms
        ms.move_r(100, 0, interval=0.5, times=30)
        exit()

    if hotkey__start:
        print(f'--- wait hotkey__start[{hotkey__start}]')
        keyboard.wait(hotkey__start)

    set_genshin_window_position()

    tt = Time()
    tt.sleep(0.5)
    beep()
    print(f'--- start abs_mouse_recorder.record, stop until press hotkey__until [{hotkey__until}]')

    if 0:
        from tools import ms
        pos_ls = []
        # from tools.recoder_args import DefaultArgs
        # interval = 1 / DefaultArgs.frames
        while tt.during(5):
            pos_i = ms.position
            pos_ls.append((pos_i, tt.now()))
            print(pos_i)
            tt.sleep(0.001)

        pos_ls
        p_ls = [pos_i[0] for pos_i in pos_ls]
        from bdtime import show_ls
        show_ls(p_ls)
        len(p_ls)

        end_beep()
        exit()

    tt.__init__()

    abs_mouse_recorder = AbsMouseRecorder(tt=tt)
    run(abs_mouse_recorder=abs_mouse_recorder, save_file_name=save_file_name, play=play_record, play_target=play_target, need_press_alt=need_press_alt, hotkey__until=hotkey__until, tt=tt)

    end_beep()


if __name__ == '__main__':
    main()
